
$('#selectStorage').change(function () {
    storageUuid = $('#selectStorage').val();
    var storageName = $("#selectStorage").find("option:selected").text();
    storageName = storageName == '请选择仓库'?'所有':storageName;
    console.log(storageName);
    $('#storageName').text(storageName);
});

function changeStorage() {
    storageUuid = $('#selectStorage').val();
    setTimeout(function () {
        $('#table').bootstrapTable('destroy');
        init();
    },500);
}

searchField  = function() {
    SearchData();
    closeDialog();
};

function closeDialog() {
    var searchText = $('#search').val();
    var field = "";
    for (var i = 0; i < $("#keyword").find("option:selected").length; i++) {
        if (i == 0) {
            field = $("#keyword").find("option:selected")[i].innerText;
        } else {
            field = field + ' or ' + $("#keyword").find("option:selected")[i].innerText;
        }
    }

    var startTime = $("#start_time").val();
    var endTime = $("#end_time").val();
    var keyword = '';
    var time = '';
    if (field != '' && searchText != '') {
        console.log(field);
        keyword = field + '=' + searchText;
    }
    if (startTime && endTime == '') {
        time = startTime + '起';
    } else if (startTime == '' && endTime) {
        time = endTime + '截止';
    } else if (startTime && endTime) {
        time = startTime + '-' + endTime;
    } else {
        time = ''
    }
    var condition = ' ';
    if(keyword && time){
        condition += keyword + ' 且 ' + time;
    }else{
        condition += keyword+time
    }
    $('#condition').text(condition);
    $("#advancedTable").hide();
}

openDialog  = function() {
    $("#advancedTable").show();
};

clearDialog =  function(){
    $("#advancedTable input").val("");
    $('#keyword').selectpicker('val', ['noneSelectedText']);
    $("#keyword").selectpicker('refresh');
    closeDialog();
};

$(document).ready(function () {
    $("#advancedTable").draggable();
});

 function setColumn() {
    if (storageUuid === '') {
        $('#table').bootstrapTable('showColumn', 'name');
    } else {
        $('#table').bootstrapTable('hideColumn', 'name');
    }
}